#ifndef MYTCPSERVER_H
#define MYTCPSERVER_H

#include <QTcpServer>
#include"mytcpsocket.h"
#include"dbmanager.h"
class MyTcpServer : public QTcpServer
{
    Q_OBJECT
public:
    explicit MyTcpServer(QObject *parent = nullptr);

    ~MyTcpServer();

    void incomingConnection(qintptr handle) override; // 当有新客户端连接服务器时，
                                                    //   这个函数会被自动触发，用于处理这个新连接

    int getTcpNums();
public slots:
    void deleteSocket(MyTcpSocket*tcpSocket);              //销毁tcp连接
    void forwardMsg(const QString& desName,PDU *pdu);      //转发消息
    void displayLog(const QString&logTxt);

signals:
    void sendDataToSocket(MyTcpSocket*tcpSocket,PDU *pdu);

private:
    QList<MyTcpSocket*> m_tcpSocketList;

    DBManager*m_dbm;

    int m_tcpId=0;
};

#endif // MYTCPSERVER_H
